package com.yxh.lib_base.ext.lifecycle

import androidx.lifecycle.*
import com.yxh.lib_base.ext.livedata.BooleanLiveData

/**
 * 作者　: yuan_xh
 * 时间　: 2022/8/13
 * 描述　: app 前台后台 监听
 */
object KtxAppLifeObserver : DefaultLifecycleObserver {

    var isForeground = BooleanLiveData()

    //在前台
    override fun onStart(owner: LifecycleOwner) {
        super.onStart(owner)
        isForeground.value = true
    }

    //在后台
    override fun onStop(owner: LifecycleOwner) {
        super.onStop(owner)
        isForeground.value = false
    }

}